package de.baumann.browser.api.net

import de.baumann.browser.api.net.base.BaseUrl
import de.baumann.browser.api.net.vo.*
import io.reactivex.Observable
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST

@BaseUrl(ApiKey.NODE_MODULE)
interface NodeApiService {

    @POST(ApiKey.QUERY_USER_TYPE)
    fun queryRole(): Observable<Result<Role>>

    @POST(ApiKey.GET_NODE_LIST)
    fun getNodeList(): Observable<Result<List<Node>>>

    @FormUrlEncoded
    @POST(ApiKey.CREATE_NODE)
    fun createNode(@Field("nodeName") nodeName: String,
                   @Field("remake") remake: String): Observable<Result<Node>>

    @FormUrlEncoded
    @POST(ApiKey.JOIN_NODE)
    fun joinNode(@Field("nodeId") nodeId: String): Observable<Result<Any>>

    @FormUrlEncoded
    @POST(ApiKey.NODE_STATUS)
    fun nodeStatus(@Field("nodeId") nodeId: String): Observable<Result<NodeStatus>>

    @FormUrlEncoded
    @POST(ApiKey.MEMBERS)
    fun members(@Field("nodeId") nodeId: String): Observable<Result<List<Member>>>


    @FormUrlEncoded
    @POST(ApiKey.REQUEST_JOIN_LIST)
    fun requestJoinList(@Field("nodeId") nodeId: String): Observable<Result<List<JoinApp>>>

    @FormUrlEncoded
    @POST(ApiKey.JOIN_VERIFY)
    fun joinVerify(@Field("applyId") applyId: String): Observable<Result<Member>>

    @FormUrlEncoded
    @POST(ApiKey.JOIN_VERIFY_ACTION)
    fun joinVerifyAction(@Field("applyId") applyId: String, @Field("status") status: Int): Observable<Result<Any>>

    @FormUrlEncoded
    @POST(ApiKey.UPDATE_NODE_DESC)
    fun updateNodeDesc(@Field("nodeId") nodeId: String, @Field("remake") remake: String): Observable<Result<Any>>

    @FormUrlEncoded
    @POST(ApiKey.NODE_DETAIL)
    fun nodeDetail(@Field("nodeId") nodeId: String): Observable<Result<NodeDetail>>
}